﻿import flash.external.*

playeruid = [player0,player1,player2,player3,player4,player5,player6,player7];       //玩家uid
	
playerready = [zb0,zb1,zb2,zb3,zb4,zb5,zb6,zb7];   //准备图片
zy = [zy_text0,zy_text1];
menulist = [btnCard0,btnCard1,btnCard2,btnCard3,btnCard4,btnCard5,btnCard6,btnCard7]
list_x = [108];
list_y = [168,200,232,264,296,328,360,392,424,456];
master_y = [200,232,264,296,360,392,424,456];
lstplayer = ["打开"];
arr = [];
//玩家uid坐标
function set_uid_pos()
{	
	count = 0;
	play_c = 0;
	for (var i:Number=0;i<arr.length;i++){
		zy[i]._x = list_x[0];
		zy[i]._y = list_y[count];
		zy[i]._visible = true;
		count+=1;
		for (var j:Number = 0;j<arr[i];j++){
			playeruid[play_c]._x = list_x[0];
			playeruid[play_c]._y = list_y[count];
			playeruid[play_c]._visible = true;
			playeruid[play_c].selected = true;
			playeruid[play_c].rowCount = 2;
			playeruid[play_c].selectedIndex = 0;
			playeruid[play_c].dataProvider = lstplayer;
			playerready[play_c]._x = 424;
			playerready[play_c]._y = list_y[count]+3;
			menulist[play_c]._x = list_x[0] + 113;
			menulist[play_c]._y = list_y[count] + 6;
			menulist[play_c]._visible = false;
			menulist[play_c].iSide = play_c;
			menulist[play_c].addEventListener("click",this,"menu_click");
					
			count+=1;
			play_c+=1;
			}
		}
}

function menu_click(e:Object){
		//menu[e.target.iSide]._visible = false; 
		ExternalInterface.call("tgame_mgr.show_menu", e.target.iSide);
	}
//是否显示玩家uid
function set_uid(master:Number,_index:Number, txt:String, is_show:Number,is_master:Number)
{
	if (is_show == 0)
	{	
		lstplayer = ["打开"];
		playeruid[_index].rowCount = 1;
		playeruid[_index].dataProvider = lstplayer;
		playeruid[_index].selected = true;
		menulist[_index]._visible = false;
		return;
	}
	if (master == _index and is_master == 1){
		lstplayer = [txt];
		playeruid[_index].rowCount = 1;
		playeruid[_index].dataProvider = lstplayer;
		playeruid[_index].selected = false;
		menulist[_index]._visible = true;
	}else if (is_master == 1){
		lstplayer = [txt,"打开"];
		playeruid[_index].rowCount = 2;
		playeruid[_index].dataProvider = lstplayer;
		playeruid[_index].selected = false;
		menulist[_index]._visible = true;
	}else{
		lstplayer = [txt];
		playeruid[_index].rowCount = 1;
		playeruid[_index].dataProvider = lstplayer;
		playeruid[_index].selected = false;
		menulist[_index]._visible = true;
	}
}

//是否显示准备图片
function is_ready(_index:Number,is_show:Number)
{
	if (is_show == 0)
	{   
		playerready[_index]._alpha = 0;
		return;
	}
	playerready[_index]._alpha = 100;
	
}
function is_ready_btn(is_show:Number)
{
	if(is_show == 0)
	{
		zb_ready.disabled = false; 
		zb_cl.disabled = true;
		zb_exit.disabled = false;
		return;
	}
	zb_ready.disabled = true; 
	zb_cl.disabled = false;
	zb_exit.disabled = true;
}
function draw_master(_index:Number,is_show:Number){
	if(is_show == 0){
		master._alpha = 0;
		return;
	}
	master._x =55;
	master._y =master_y[_index];
	master._alpha = 100;
}
/*function draw_zb_map(_stage:Number){
	mc = _root.createEmptyMovieClip("map_zb", 0);
	mc.loadMovie("map"+_stage+".png".toString());
	mc._x =840;
	mc._y = 120;
}*/

function change_map(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_map", e.index);
}
dropMap.addEventListener("change", this, "change_map");
//============================================================
function change_player0(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,0);
}
player0.addEventListener("change", this, "change_player0");
function change_player1(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,1);
}
player1.addEventListener("change", this, "change_player1");
function change_player2(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,2);
}
player2.addEventListener("change", this, "change_player2");
function change_player3(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,3);
}
player3.addEventListener("change", this, "change_player3");
function change_player4(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,4);
}
player4.addEventListener("change", this, "change_player4");
function change_player5(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,5);
}
player5.addEventListener("change", this, "change_player5");
function change_player6(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,6);
}
player6.addEventListener("change", this, "change_player6");
function change_player7(e:Object)
{
	ExternalInterface.call("tgame_mgr.change_player", e.index,7);
}
player7.addEventListener("change", this, "change_player7");
//=========1:可换 0:不可=============================================================
function go_player0(e:Object)
{
	if (player0.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,0);
}
player0.addEventListener("click", this, "go_player0");
function go_player1(e:Object)
{
	if (player1.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,1);
}
player1.addEventListener("click", this, "go_player1");
function go_player2(e:Object)
{
	if (player2.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,2);
}
player2.addEventListener("click", this, "go_player2");
function go_player3(e:Object)
{
	if (player3.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,3);
}
player3.addEventListener("click", this, "go_player3");
function go_player4(e:Object)
{
	if (player4.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,4);
}
player4.addEventListener("click", this, "go_player4");
function go_player5(e:Object)
{
	if (player5.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,5);
}
player5.addEventListener("click", this, "go_player5");
function go_player6(e:Object)
{
	if (player6.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,6);
}
player6.addEventListener("click", this, "go_player6");
function go_player7(e:Object)
{
	if (player7.selected == true)
		b = 1;
	else
		b = 0;
	ExternalInterface.call("tgame_mgr.go_side",b,7);
}
player7.addEventListener("click", this, "go_player7");
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
lstSelectableMap = [];

dropMap.rowCount = 3;
function set_dropmap()
{
	dropMap.dataProvider = lstSelectableMap;
}
function ready()
{		
	ExternalInterface.call("tgame_mgr.ready");

}
zb_ready.addEventListener("click", this, "ready");

function exit()
{
	ExternalInterface.call("tgame_mgr.exit");
}
zb_exit.addEventListener("click", this, "exit");
function ready_cl(){
	ExternalInterface.call("tgame_mgr.ready_cl");
}
zb_cl.addEventListener("click", this, "ready_cl");

//arr = [1,1];
//set_uid_pos();
//set_uid(1,0,"dasdasdasd",1,0);
//set_uid(0,1,"aaa",1,0);
//draw_master(0,1);
